﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;

namespace com.lover.astd.common.logicexe.activities
{
    public class DailyTreasureGameExe : ExeBase
    {
        public DailyTreasureGameExe() { _name = ConfigStrings.S_Daily_Treasure_Game; _readable = ConfigStrings.SR_Daily_Treasure_Game; }
        public override long execute()
        {
            int _minGoldSteps = 0;
            string _open_box_type = "", _gold_move_box_type = "";
            Dictionary<string, string> conf = getConfig();
            if (!conf.ContainsKey(ConfigStrings.enabled) || !conf[ConfigStrings.enabled].ToLower().Equals("true")) return next_day();
            if (conf.ContainsKey(ConfigStrings.goldstep)) Int32.TryParse(conf[ConfigStrings.goldstep], out _minGoldSteps);
            if (conf.ContainsKey(ConfigStrings.open_box_type)) _open_box_type = conf[ConfigStrings.open_box_type];
            if (conf.ContainsKey(ConfigStrings.gold_move_box_type)) _gold_move_box_type = conf[ConfigStrings.gold_move_box_type];

            ActivityMgr mgr = ServiceFactory.getActivityManager();
            int gold_available = getGoldAvailable();
            int silver_available = _user.Silver;
            int result = mgr.handleDailyTreasureGameInfo(_proto, _logger, _user, _open_box_type, _gold_move_box_type,
                _minGoldSteps, ref gold_available, ref silver_available);
            if (result == 1) return next_hour();
            else if (result == 2) return next_hour();
            else if (result == 3)
            {
                logInfo("想用银币开启日常探宝, 奈何银币太少了吧, 下个小时再看看吧");
                return next_hour();
            }
            if (result == 10) return next_hour();
            return immediate();
        }
    }
}
